package com.base.vistter.iframe.inverter.controller;

import com.base.vistter.iframe.bean.Result;
import com.base.vistter.iframe.entity.SysRole;
import com.base.vistter.iframe.exception.IframeException;
import com.base.vistter.iframe.service.SysRoleMenuService;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@Slf4j
@RequestMapping("/sys/role/menu")
public class SysRoleMenuController {

    @Resource(name = "sysRoleMenuService")
    private SysRoleMenuService sysRoleMenuService;

    @PostMapping(produces = "application/json;charset=utf-8")
    public Result<Boolean> permission(@RequestBody SysRole sysRole) throws IframeException {
        return Result.ok(sysRoleMenuService.permission(sysRole));
    }

    @GetMapping
    public Result<List<Integer>> getMenuIds(@RequestParam("id") Integer roleId) throws IframeException{
        return Result.ok(sysRoleMenuService.getMenuIds(roleId));
    }
}
